Skip to content

fix(service-print, spec): the print door's 5xx sentences follow the request's language - #37272

Draft
objectstack-fleet[bot] wants to merge 1 commit into
mainfrom
claude/issue-37260-print-failure-locale
Draft

objectstack-fleet[bot] wants to merge 1 commit into
mainfrom
claude/issue-37260-print-failure-locale

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #37260

repo:objectstack#4 · os-justin · session_01QSeKYnagJvGbCtNg2PhvgW

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:在中文(以及日文、西班牙文)界面里点击打印,若服务器上的打印引擎未就绪、打印超时或服务器出错,提示条现在用界面语言显示;英文界面与以前一字不差。
  • 为什么做:报价单打印失败时中文界面弹出整句英文,看起来像坏了,业务用户也看不懂;这是该缺陷卡(打印失败提示不跟随界面语言)本身。
  • 出错会怎样:最坏情况是某种语言的提示措辞不够好,状态码与错误码都不变,不影响打印本身;可直接撤回本改动。
  • 要你做什么:无。

What changes

  • packages/spec/src/system/operation-message.ts: four keys in the platform's operation-message catalog (BUILTIN_OPERATION_MESSAGES), in all four locales it carries (en, zh-CN, ja-JP, es-ES): print_engine_unavailable (503), print_timed_out (504), print_failed (the 5xx fallback) and print_caller_unresolved (the door's caller-resolution 500). English is byte-identical to the fixed text the door answered before. No placeholder; the header documents them beside the other keys.
  • packages/services/service-print/src/print-routes.ts: serverAnswerFor(status, locale) maps the status to its catalog key and renders it through operationUserMessage (@objectstack/core), the shared helper the platform's other localized refusals use; relayPrintFailure and the caller-resolution fault pass the request's top Accept-Language tag (preferredLocaleFromHeader). The door reads no query parameter, so ?locale is not a source. Code, status, the fault log and the 4xx relay are unchanged.
  • packages/services/service-print/vitest.config.ts: aliases @objectstack/spec/system to source like the other spec subpaths, so the new import is judged against this checkout, never a stale dist/.

The mechanism reused, not a new one: the operation-message catalog plus operationUserMessage is the platform's one seat for localized user-facing server sentences (its header: "a second mechanism for the second producer is exactly what this module exists to prevent"). The door's message itself is localized, because sendServerFault's message is already the route's generic user-facing text (the thrown detail goes only to the fault log) and sendServerFault declares no userMessage channel; widening it would change an @objectstack/types export outside this card's file surface.

The action path from the repro (POST /api/v1/actions/crm_quote/print_quote) produces no sentence of its own for these failures: the /actions door forwards a same-origin type: 'api' action in-process with accept-language on its header allowlist (API_FORWARD_HEADER_ALLOWLIST, packages/runtime/src/action-execution.ts) and relays the target's refusal envelope with its message as written (restAnswerOf, forward-refused, packages/runtime/src/action-dispatch.ts). So fixing the door fixes the action toast; nothing changed in packages/runtime.

Bounded in-place fix, declared: the caller-resolution 500 (The caller of this print could not be resolved.) is the same door's own 5xx sentence, the same defect class, the same file in the claim's surface, the same gate family; it is localized the same way and pinned below.

Read first

  1. packages/services/service-print/src/print-routes.ts (the requestLocaleOf / serverAnswerKeyFor / serverAnswerFor hunk) — the only behaviour change.
  2. packages/spec/src/system/operation-message.ts — the 16 new catalog strings; the zh-CN, ja-JP and es-ES wording is the review risk.
  3. packages/services/service-print/src/print-routes.test.ts — the new top-level describe.

Two-minute verification

pnpm --filter @objectstack/service-print exec vitest run --maxWorkers=2 src/print-routes.test.ts — expect 36 passed, including ten under "its own 5xx sentences, in the request's language".

Tests

All at head 3dfbfdb5a.

  • pnpm --filter @objectstack/service-print test — Test Files 9 passed (9), Tests 145 passed (145).
  • pnpm --filter @objectstack/spec test — Test Files 891 passed (891), Tests 28371 passed, 1 todo.
  • pnpm --filter @objectstack/service-print typecheck exit 0; pnpm --filter @objectstack/spec typecheck exit 0 (tsc, scripts and test typecheck).
  • New pins (door, print-routes.test.ts): 503, 504 and 500 under accept-language: zh-CN,zh;q=0.9,en;q=0.8 answer the zh-CN catalog sentence and not the English one; the control: en-US and an absent header answer the English sentence, for each of the three; the English sentences equal the pre-change text; ja reaches ja-JP and de-DE falls back to English; the caller-resolution 500 in zh-CN and absent; a 4xx keeps its producer's text under zh-CN.
  • New pins (catalog, operation-message.test.ts): all four keys in every locale, placeholder-free, naming no wire code or host vocabulary, distinct from every other key, rendering zh-CN / es / en fallback.
Ablation: hard-coded English restored, zh pins turn red

node scripts/ablation-replace.mjs on print-routes.ts, anchor return operationUserMessage(serverAnswerKeyFor(status), { locale }); replaced with the three original hard-coded English returns. The test imports the subject by relative path and aliases core/spec to source, so no build stands between the mutation and the run.

ablation-replace: anchor   x1 -> x0
ablation-replace: blob     44b2c38dcc4e216ca81b7084f1f0377340c18dd0 -> 97403a9b77a977dc80088aafb8a207052ec53393
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 44b2c38dcc4e -> 97403a9b77a9
     × no print engine ready: SERVICE_UNAVAILABLE / 503 under accept-language zh-CN answers the zh-CN sentence
     × the render ran past its time: TIMEOUT / 504 under accept-language zh-CN answers the zh-CN sentence
     × an undeclared fault: INTERNAL_ERROR / 500 under accept-language zh-CN answers the zh-CN sentence
     × a base language reaches its regional catalog (ja → ja-JP); a language the catalog lacks answers English
      Tests  4 failed | 32 passed (36)
ablation-replace: ok restored: blob == HEAD (44b2c38dcc4e) and `git diff HEAD` is empty

The three English controls stayed green under the mutation, as they should.

Gates

node scripts/pm/dispatch-gates.mjs --commands derived 91 families for this diff; all 91 were run at 3dfbfdb5a, each exit captured before any pipe. Reconciliation (--ran with exit codes): ✓ 91 derived famil(ies) accounted for — 88 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3).

  • 88 exit 0.
  • NOT MEASURED: node scripts/check-plugin-teardown-shape.mjs --self-test, reason: shallow clone cannot reach its pinned positive-control commit.
  • NOT MEASURED: pnpm check:dual-build-cjs-loads, reason: reads every package's built output; only the service-print closure was built here.
  • NOT MEASURED: pnpm check:type-check-debt, reason: its re-measure queued on the shared verify lock behind a long dogfood run (exit 99 twice).

All three run in CI on this PR. test:repo was not run locally (no diff in that project); declared to CI's Test Core.

Acceptance notes

  • The language source is the request's Accept-Language only. The door's execution context carries no locale and no workspace default (requestLocale: undefined, localization: undefined), so operationUserMessage's second rung (the workspace default) has nothing to read here; the console sends its UI language on every call, which is the issue's case.
  • No deployment errors.print_* translation override is consulted: operationUserMessage is the helper for producers that hold no i18n service, and the door holds none.
  • The door's own 4xx refusals (the impersonation refusal, the request-shape refusals) stay English developer text; they are outside this card, which names the 5xx sentences.
  • Observation only, not filed: the /actions door's own forward-unavailable sentence (apiActionForwardUnavailableError, 503) and the print bridge's 501 are English too; neither is on this card's path when the door is mounted, and neither was reproduced here.
  • Clause-② measured: no new export, no type change, no new envelope field, no new input read as a contract (any header was already accepted); the catalog gains entries in an existing exported Record value, and the wire message changes language only for a non-English request.

Generated by Claude Code

…equest's language

serverAnswerFor answered fixed English for 503, 504 and the 500 fallback, and
the caller-resolution 500 did the same, whatever the request's Accept-Language.
The four sentences are now print_* keys of the platform's operation-message
catalog (BUILTIN_OPERATION_MESSAGES) in en, zh-CN, ja-JP and es-ES, written
through operationUserMessage in the request's top Accept-Language tag. English
is byte-identical to the old text.

Claude-Session: https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation protocol:system tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/service-print, @objectstack/spec, touching 16 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/services/service-print/vitest.config.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/client-sdk.mdx (via INTERNAL_ERROR (literal, a string literal in handlePrintRecord))
  • content/docs/api/error-catalog.mdx (via INTERNAL_ERROR (literal, a string literal in handlePrintRecord))
  • content/docs/automation/hook-bodies.mdx (via INTERNAL_ERROR (literal, a string literal in handlePrintRecord))
  • content/docs/permissions/system-context.mdx (via INTERNAL_ERROR (literal, a string literal in handlePrintRecord))
  • content/docs/plugins/development.mdx (via INTERNAL_ERROR (literal, a string literal in handlePrintRecord))
  • content/docs/protocol/kernel/error-handling.mdx (via INTERNAL_ERROR (literal, a string literal in handlePrintRecord))
  • content/docs/ui/print-pages.mdx (via /api/v1/print/records (route, a path literal in a comment on a changed line))

⛔ 3 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via INTERNAL_ERROR (literal, a string literal in handlePrintRecord))
  • content/docs/releases/v18/18-2.mdx (via INTERNAL_ERROR (literal, a string literal in handlePrintRecord))
  • content/docs/releases/v18/18-3.mdx (via INTERNAL_ERROR (literal, a string literal in handlePrintRecord))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/services/service-print/vitest.config.ts) — pages documenting those are invisible to this run
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 177 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 057cedfa9b6f990a7cf322118ae33bc4460ddc65 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 97c160b65ebc105e8f484700fe6c88081e107428 — the merge of head 3dfbfdb5a135338fd76d80ceab81442c2315d4df into base 057cedfa9b6f990a7cf322118ae33bc4460ddc65, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 97c160b65ebc105e8f484700fe6c88081e107428 && git checkout 97c160b65ebc105e8f484700fe6c88081e107428
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 057cedfa9b6f990a7cf322118ae33bc4460ddc65 3dfbfdb5a135338fd76d80ceab81442c2315d4df && git checkout -B drift-repro 057cedfa9b6f990a7cf322118ae33bc4460ddc65 && git merge --no-ff 3dfbfdb5a135338fd76d80ceab81442c2315d4df

node scripts/docs-audit/affected-docs.mjs --json 057cedfa9b6f990a7cf322118ae33bc4460ddc65

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 057cedfa9b6f990a7cf322118ae33bc4460ddc65 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:system size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Print failure messages (503 'print engine is not ready', 504, 500) are hard-coded English and ignore the request locale

2 participants